<template>
    <div>
        <div class="topheader" v-if="lists">
            <div class="img" :style="{'background-image':'url('+picUrl+')'}">
                <!-- <img :src="picUrl" alt=""> -->
            </div>
            <div class="title">{{lists.name}}</div>
            <div class="button" @click="back()">
                <span class="iconfont icon-arrow-left-bold">
                    <span></span>
                </span>
            </div>
            <dl class="musicList">
                <dt>
                    <i class="iconfont icon-bofang"></i>播放全部<span>(共{{lists.length}}首)</span>
                </dt>
                <dd v-for="(item,index) in lists" :key="index" @click="setId(item.id)">
                    <h1>{{index+1}}</h1>
                    <div class="info">
                        <h2>{{item.name}}</h2>
                        <h3><span v-for="(k,i) in item.ar" :key="i">{{k.name}}&nbsp;</span></h3>
                    </div>
                </dd>
            </dl>
        </div>
    </div>
</template>
<script>
import {getSingertopsong} from "../api/singer.js"
export default {
    data() {
        return {
            lists:null,
            picUrl:null
        }
    },
    methods: {
        back(){
                this.$router.go(-1);
            },
          getSingertopsongFun(){
            let id = this.$route.query.id;
            this.picUrl = this.$route.query.picUrl;
            console.log(id);
                 getSingertopsong({id}).then(data=>{
                    console.log(data);
                    this.lists=data.songs;
                    
                    // console.log(this.lists);
                })            
            
        },
                setId(id){
                this.$emit("get-player-id",id);
            },
            playAll(){
            this.$emit("get-play-all-id",this.$route.query.id);
            this.$emit("get-player-id",this.lists[0].id);
        }    
    },
    mounted() {
        this.$nextTick(() => { 
            this. getSingertopsongFun();
        })
    },
}
</script>
<style lang="less">
 .topheader{
        position: relative;
        height: 270px;
        .img{
            background-color: aqua;
            width: 100%;
            height: 270px;
            position: relative;
            background-size: cover;
            background-repeat: no-repeat;
            background-position: center center;
            // img{
            //     position: absolute;
            //     top: 0px;
            //     left: 0px;
            //     right: 0px;
            //     bottom: 0px;
            //     margin: auto;
            //     width: 100%;
            // }
        }
        .title{
            font-size: 18px;
            position: absolute;
            left: 18px;
            bottom: 18px;
            color: white;
        }
        .button{
            font-size: 18px;
            position: absolute;
            left: 12px;
            top: 12px;
            color: white;
        }
    }
    .musicList{
        background-color: #fff;
        width: 100%;
        border-radius: 7px;
        position: relative;
        top: -7px;
        overflow: hidden;
        dt{
            height: 36px;
            line-height: 36px;
            font-size: 16px;
            color: #454747;
            border-bottom: 1px solid #E3E3E3;
            span{
                font-size: 14px;
                color: #797B7A;
            }
            i{
                width: 44px;
                text-align: center;
                // margin-left: 5px;
                display: inline-block;
            }
        }
        dd{
            display: flex;
            height: 53px;
            border-bottom: 1px solid #E3E3E3;
            h1{
                flex: 0 0 44px;
                line-height: 53px;
                text-align: center;
                font-size: 16px;
                color: #6D6E6E;
            }
            .info{
                flex: 1;
                h2{
                    font-size: 16px;
                    color: #1B1C1C;
                    margin-top: 10px;
                    white-space: nowrap;
                    width: 100%;
                    
                    // text-overflow: ellipsis;
                }
                h3{
                    font-size: 12px;
                    color: #929393;
                }
            }
        }
    }
</style>